package com.ifox.hgx.spring.annotation.test;

        import com.ifox.hgx.spring.annotation.aop.MathCalculator;
        import com.ifox.hgx.spring.annotation.config.MainConfigOfAOP;
        import org.junit.Test;
        import org.springframework.context.annotation.AnnotationConfigApplicationContext;

public class IOCTest_AOP {

    @Test
    public void test01() {
        AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext(MainConfigOfAOP.class);

        //1、不要自己创建对象
//		MathCalculator mathCalculator = new MathCalculator();
//		mathCalculator.div(1, 1);
        MathCalculator mathCalculator = applicationContext.getBean(MathCalculator.class);

//        mathCalculator.div(1, 0);
        mathCalculator.div(4, 2);
        applicationContext.close();
    }

}

/**
 * div运行。。。@Before:参数列表是：{[4, 2]}
 * MathCalculator...div...
 * div结束。。。@After
 * div正常返回。。。@AfterReturning:运行结果：{2}
 */
